<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
          
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <f:metadata>
            <f:viewParam name="page" value="#{patientBean.page}"/>
            <f:viewParam name="drugName" value="#{patientBean.patientSearchName}"/>
        </f:metadata>         
    </h:head>
    <h:body>
        <ui:composition template="template/masterlayout.xhtml">
            <ui:define name="pagetitle">
                Patients management
            </ui:define>
            <ui:define name="breadcrumb">
                <h:link value="Dashboard" outcome="index"/> &raquo; <h:link value="Patients management" outcome="patients"/>
            </ui:define>
            <ui:define name="content">
                <div class="alert-box #{patientBean.messageStyle}"><span>#{patientBean.messageStyle} </span>#{patientBean.message}</div>
                <h:form styleClass="searchform">
                    <h:outputLabel for="patientName">Patient Name: </h:outputLabel>
                    <h:inputText id="patientName" value="#{patientBean.patientSearchName}"/>
                    <h:commandButton styleClass="button-submit" value="Search Patient" action="patients"/>
                </h:form>
                <div class="clear"></div>                
                <h:form>
                    <h:dataTable value="#{patientBean.patients}" var="patient" columnClasses="patientName,patientAddress,patientPhoneNumber,action">
                        <h:column>
                            <f:facet name="header">Patient Name</f:facet>
                            #{patient.patientName}
                        </h:column>
                        <h:column>
                            <f:facet name="header">Patient Address</f:facet>
                            #{patient.patientAddress}
                        </h:column>
                        <h:column>
                            <f:facet name="header">Patient Phone</f:facet>
                            #{patient.patientPhoneNumber}
                        </h:column>
                        <h:column>
                            <f:facet name="header">Action</f:facet>
                            <h:link styleClass="view" value="View" outcome="patient">
                                <f:param name="patientID" value="#{patient.patientID}"/>
                            </h:link>
                            <h:link styleClass="edit" value="Edit" outcome="editpatient">
                                <f:param name="patientID" value="#{patient.patientID}"/>
                            </h:link>
                            <h:commandLink styleClass="delete" value="Delete" action="#{patientBean.deletePatient(patient.patientID)}"></h:commandLink>
                        </h:column>
                    </h:dataTable>
                </h:form>
                <ul id="pagination-digg">
                    <ui:repeat value="#{patientBean.pagings}" var="page">
                        <li>
                            <h:link outcome="patients" value="#{page}">
                                <f:param name="page" value="#{page}"/>
                                <f:param name="patientName" value="#{patientBean.patientSearchName}"/>
                            </h:link>
                        </li>    
                    </ui:repeat>
                </ul>                
            </ui:define>
        </ui:composition>
    </h:body>
</html>

